﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace KD.Sms.CustomControl
{
    public partial class NetState : UserControl
    {
        public NetState()
        {
            InitializeComponent();
        }

        public NetState(string title, string ip)
        {
            InitializeComponent();
            C_Title = title;
            C_IP = ip;
        }

        /// <summary>
        /// 显示文本
        /// </summary>
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("Text")]
        [System.ComponentModel.Description("显示文本")]
        [System.ComponentModel.DefaultValue("")]//默认值
        public string C_Title
        {
            set { labTitle.Text = value; }
            get { return labTitle.Text; }
        }



        /// <summary>
        /// 显示文本
        /// </summary>
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("Text")]
        [System.ComponentModel.Description("显示文本")]
        [System.ComponentModel.DefaultValue("")]//默认值
        public string C_IP
        {
            set { labIP.Text = value; }
            get { return labIP.Text; }
        }

        public void DoPing()
        {
            Thread thPing = new Thread(new ThreadStart(Ping)) { IsBackground = true };
            thPing.Start();
        }

        private void Ping()
        {
            UI.FormHelper.SetGroundImage(picState, NetJudger.DoJudge(C_IP) ? KD.Sms.Properties.Resources.run : KD.Sms.Properties.Resources.Waring);
        }

    }
}
